package opera1;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation  implements  IOperation{
    @Override
    public void doWork(BookList bookList) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入你要查找的书名:");
        String name = input.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if (name.equals(book.getName())) {
                System.out.println("找到了!");
                System.out.println(book.toString());
                break;
            }
        }
    }
}
